﻿namespace OverStore.Exceptions
{
    using System;
    using System.Globalization;

    /// <summary>
    /// The exception that is throws when trying to access instance in session
    /// using valid object type but wrong identifier type.
    /// </summary>
    public class IdentifierTypeIsInvalidException : ArgumentException
    {
        /// <summary>
        /// Initializes new instance of <see cref="IdentifierTypeIsInvalidException"/> class.
        /// </summary>
        public IdentifierTypeIsInvalidException(Type objectType, Type identifierType)
            : base(String.Format(CultureInfo.InvariantCulture, "Object of type {0} has identifier with type different from {1}.", objectType, identifierType))
        {
            if (objectType == null)
                throw new ArgumentNullException("objectType");
            if (identifierType == null)
                throw new ArgumentNullException("identifierType");
            ObjectType = objectType;
            IdentifierType = identifierType;
        }

        /// <summary>
        /// Get object type requested from repository.
        /// </summary>
        public Type ObjectType { get; private set; }

        /// <summary>
        /// Get identifier type requested from repository.
        /// </summary>
        public Type IdentifierType { get; private set; }
    }
}
